package com.framework.wz.wutong.ui.activity;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.EditText;
import android.widget.ImageView;

import com.framework.wz.wutong.R;
import com.framework.wz.wutong.base.BaseActivity;
import com.framework.wz.wutong.ui.adapter.NoticeListAdapter;
import com.framework.wz.wutong.ui.contract.NoticeListContract;
import com.framework.wz.wutong.ui.presenter.NoticeListPresenter;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.constant.SpinnerStyle;
import com.scwang.smartrefresh.layout.footer.ClassicsFooter;
import com.scwang.smartrefresh.layout.header.ClassicsHeader;
import com.scwang.smartrefresh.layout.listener.OnLoadMoreListener;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;

import butterknife.BindView;
import butterknife.OnClick;
import okhttp3.ResponseBody;

public class NoticeListActivity extends BaseActivity implements NoticeListContract.View {

    @BindView(R.id.noticeListBackImg)
    ImageView          noticeListBackImg;
    @BindView(R.id.noticeListSearchEdit)
    EditText           noticeListSearchEdit;
    @BindView(R.id.noticeListRv)
    RecyclerView       noticeListRv;
    @BindView(R.id.noticeListSrl)
    SmartRefreshLayout noticeListSrl;
    private NoticeListPresenter presenter;
    private NoticeListAdapter noticeListAdapter;

    @Override
    protected int attachLayoutRes() {
        return R.layout.activity_notice_list;
    }

    @Override
    protected void initView() {
        presenter = new NoticeListPresenter();
        presenter.attachView(this);
        initSmartRefreshLayout();
        initRecyclerView();
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void initListener() {

    }

    private void initSmartRefreshLayout() {
        noticeListSrl.setRefreshHeader(new ClassicsHeader(this).setSpinnerStyle(SpinnerStyle.Translate));
        noticeListSrl.setRefreshFooter(new ClassicsFooter(this).setSpinnerStyle(SpinnerStyle.Translate));
        noticeListSrl.setEnableLoadMore(false);
        noticeListSrl.setEnableRefresh(false);
        noticeListSrl.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh(@NonNull RefreshLayout refreshLayout) {

            }
        });
        noticeListSrl.setOnLoadMoreListener(new OnLoadMoreListener() {
            @Override
            public void onLoadMore(@NonNull RefreshLayout refreshLayout) {

            }
        });
    }

    private void initRecyclerView() {
        LinearLayoutManager lm = new LinearLayoutManager(this);
        noticeListRv.setLayoutManager(lm);
        noticeListAdapter = new NoticeListAdapter(this);
        noticeListRv.setAdapter(noticeListAdapter);
    }

    @Override
    public void showProgress() {
        showDialog(true);
    }

    @Override
    public void dismissProgress() {
        showDialog(false);
    }

    @Override
    public Context getContext() {
        return null;
    }

    @Override
    public void getNoticeList() {
        presenter.getNoticeList();
    }

    @Override
    public void showNoticeList(ResponseBody body) {

    }

    @Override
    public int getPage() {
        return 0;
    }

    @Override
    public int getPageSize() {
        return 0;
    }

    @Override
    public void setPage() {

    }

    @OnClick(R.id.noticeListBackImg)
    public void onClick() {
        finish();
    }
}
